<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网站分类管理 - 控制面板</title>
    <link rel="stylesheet" href="/css/style.css">
    <style>
        .table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            margin-bottom: 20px;
            background-color: rgba(30, 30, 30, 0.7);
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        }
        
        .table th, .table td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid rgba(100, 150, 200, 0.2);
        }
        
        .table thead th {
            background-color: rgba(20, 20, 30, 0.8);
            color: rgba(200, 230, 255, 0.9);
            font-weight: 600;
            position: sticky;
            top: 0;
        }
        
        .table tbody tr {
            transition: all 0.3s ease;
        }
        
        .table tbody tr:hover {
            background-color: rgba(40, 50, 80, 0.5);
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        }
        
        .table tbody tr:last-child td {
            border-bottom: none;
        }
        
        .btn {
            display: inline-block;
            padding: 6px 12px;
            background: linear-gradient(145deg, rgba(0, 120, 210, 0.8), rgba(0, 80, 160, 0.8));
            color: white;
            text-decoration: none;
            border-radius: 4px;
            border: none;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
        }
        
        .btn:hover {
            background: linear-gradient(145deg, rgba(0, 140, 230, 0.9), rgba(0, 100, 180, 0.9));
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }
        
        .btn-sm {
            padding: 4px 8px;
            font-size: 12px;
        }
        
        .btn-success {
            background: linear-gradient(145deg, rgba(0, 180, 50, 0.8), rgba(0, 140, 30, 0.8));
        }
        
        .btn-success:hover {
            background: linear-gradient(145deg, rgba(0, 200, 60, 0.9), rgba(0, 160, 40, 0.9));
        }
        
        .btn-danger {
            background: linear-gradient(145deg, rgba(220, 50, 50, 0.8), rgba(180, 30, 30, 0.8));
        }
        
        .btn-danger:hover {
            background: linear-gradient(145deg, rgba(240, 70, 70, 0.9), rgba(200, 50, 50, 0.9));
        }
        
        .action-buttons {
            display: flex;
            gap: 5px;
        }
        
        .alert {
            padding: 15px;
            margin-bottom: 20px;
            border-radius: 8px;
            backdrop-filter: blur(10px);
        }
        
        .alert-success {
            background-color: rgba(40, 180, 80, 0.2);
            color: #2ecc71;
            border: 1px solid rgba(46, 204, 113, 0.3);
        }
        
        .alert-danger {
            background-color: rgba(180, 40, 40, 0.2);
            color: #e74c3c;
            border: 1px solid rgba(231, 76, 60, 0.3);
        }
        
        .dashboard-container {
            display: flex;
            min-height: 100vh;
        }
        
        .main-content {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
        }
        
        .dashboard-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .dashboard-title h1 {
            margin: 0;
            font-size: 24px;
            color: #fff;
        }
        
        .empty-message {
            text-align: center;
            padding: 40px;
            background-color: rgba(30, 30, 30, 0.7);
            border-radius: 10px;
            margin-top: 20px;
            color: rgba(180, 190, 210, 0.8);
        }
    </style>
</head>
<body>
    <div class="dashboard-container">
        <div class="sidebar">
            <div class="sidebar-header">
                <h2>控制面板</h2>
            </div>
            <ul class="sidebar-menu">
                <li><a href="/dashboard">主页</a></li>
                <li><a href="/dashboard/profile">个人信息</a></li>
                <li><a href="/dashboard/change-password">修改密码</a></li>
                <li><a href="/dashboard/documents">文档管理</a></li>
                <li><a href="/dashboard/categories">分类管理</a></li>
                <li><a href="/dashboard/weblinks">网站链接</a></li>
                <li class="active"><a href="/dashboard/link-categories">网站分类</a></li>
                <li><a href="/danmaku-display">弹幕墙</a></li>
                <li><a href="/" target="_blank">访问首页</a></li>
                <li><a href="/logout">退出登录</a></li>
            </ul>
        </div>
        
        <div class="main-content">
            <div class="dashboard-header">
                <div class="dashboard-title">
                    <h1>网站分类管理</h1>
                </div>
                <div>
                    <a href="/dashboard/link-categories/new" class="btn btn-success">添加新分类</a>
                </div>
            </div>
            
            <!-- 成功/错误消息 -->
            <div th:if="${successMessage != null}" class="alert alert-success" th:text="${successMessage}"></div>
            <div th:if="${errorMessage != null}" class="alert alert-danger" th:text="${errorMessage}"></div>
            
            <!-- 分类列表 -->
            <div th:if="${categories != null && !categories.isEmpty()}">
                <table class="table">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>名称</th>
                            <th>描述</th>
                            <th>显示顺序</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:each="category : ${categories}">
                            <td th:text="${category.id}">1</td>
                            <td th:text="${category.name}">分类名称</td>
                            <td th:text="${category.description ?: '-'}">分类描述</td>
                            <td th:text="${category.displayOrder}">0</td>
                            <td th:text="${#temporals.format(category.createdAt, 'yyyy-MM-dd HH:mm')}">2023-10-01 12:00</td>
                            <td>
                                <div class="action-buttons">
                                    <a th:href="@{/dashboard/link-categories/edit/{id}(id=${category.id})}" class="btn btn-sm">编辑</a>
                                    <a th:href="@{/dashboard/link-categories/delete/{id}(id=${category.id})}" class="btn btn-sm btn-danger" 
                                       onclick="return confirm('确定要删除这个分类吗？这将会移除所有关联的网站链接中的分类信息。')">删除</a>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <!-- 当没有分类时显示的提示 -->
            <div th:if="${categories == null || categories.isEmpty()}" class="empty-message">
                <p>暂无网站分类。</p>
                <p>
                    <a href="/dashboard/link-categories/new" class="btn btn-success">添加网站分类</a>
                </p>
            </div>
        </div>
    </div>
</body>
</html> 